import pygame
import sys
from init_map import InitMap


class Map(InitMap):
    def __init__(self, *args):
        InitMap.__init__(self)

        self.key_yellow = pygame.image.load("../资源/图片/黄钥匙.jpg").convert_alpha()
        self.door_yellow = pygame.image.load("../资源/图片/黄门.jpg").convert_alpha()
        self.door_blue = pygame.image.load("../资源/图片/蓝门.png").convert_alpha()
        self.hp_red = pygame.image.load("../资源/图片/红药.jpg").convert_alpha()
        self.gem_blue = pygame.image.load("../资源/图片/蓝宝石.jpg").convert_alpha()
        self.gem_red = pygame.image.load("../资源/图片/红宝石.jpg").convert_alpha()
        self.black_head = pygame.image.load("../资源/图片/青头怪.jpg").convert_alpha()
        self.kulou_leader = pygame.image.load("../资源/图片/骷髅队长.png").convert_alpha()
        self.primary_guard = pygame.image.load("../资源/图片/初级卫兵.png").convert_alpha()
        self.monster_king = pygame.image.load("../资源/图片/怪王.png").convert_alpha()
        self.big_bat = pygame.image.load("../资源/图片/大蝙蝠.png").convert_alpha()
        self.red_bat = pygame.image.load("../资源/图片/红蝙蝠.png").convert_alpha()
        self.mayi_master = pygame.image.load("../资源/图片/麻衣法师.png").convert_alpha()
        self.white_warrior = pygame.image.load("../资源/图片/白衣武士.png").convert_alpha()

        self.hero_pos = (0, 1)
        self.up_pos = (6, 4)
        self.down_pos = (0, 0)
        self.variable_pos = {
            (4, 9): (self.door_yellow, '黄门'),
            (5, 1): (self.door_yellow, '黄门'),
            (7, 1): (self.door_yellow, '黄门'),
            (8, 7): (self.door_yellow, '黄门'),
            (6, 2): (self.door_blue, '蓝门'),
            (8, 0): (self.key_yellow, '黄钥匙'),
            (4, 4): (self.hp_red, '红药'),
            (4, 5): (self.hp_red, '红药'),
            (2, 5): (self.gem_blue, '蓝宝石'),
            (10, 2): (self.gem_red, '红宝石'),
            (3, 8): (self.kulou_leader, '骷髅队长'),
            (9, 0): (self.kulou_leader, '骷髅队长'),
            (6, 8): (self.kulou_leader, '骷髅队长'),
            (0, 4): (self.big_bat, '大蝙蝠'),
            (0, 5): (self.red_bat, '红蝙蝠'),
            (9, 6): (self.red_bat, '红蝙蝠'),
            (0, 6): (self.big_bat, '大蝙蝠'),
            (2, 6): (self.black_head, '青头怪'),
            (2, 7): (self.black_head, '青头怪'),
            (10, 3): (self.black_head, '青头怪'),
            (10, 4): (self.black_head, '青头怪'),
            (6, 7): (self.primary_guard, '初级卫兵'),
            (2, 10): (self.mayi_master, '麻衣法师'),
            (4, 3): (self.mayi_master, '麻衣法师'),
            (7, 10): (self.monster_king, '怪王'),
            (9, 10): (self.monster_king, '怪王'),
            (8, 10): (self.white_warrior, '白衣武士'),
        }

    def fixed_brick(self):
        self.draw(self.upstairs, self.up_pos[0], self.up_pos[1])
        self.dic[self.up_pos] = '上楼'
        self.draw(self.downstairs, self.down_pos[0], self.down_pos[1])
        self.dic[self.down_pos] = '下楼'
        for i in range(10):
            self.draw(self.wall, 1, i)
            self.dic[(1, i)] = '墙'
        for i in [(2, 9), (3, 9), (4, 1), (3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7), (4, 7), (5, 7), (5, 8),
                  (5, 9), (5, 10), (6, 0), (6, 1), (8, 1), (9, 1), (9, 2), (9, 3), (9, 4), (9, 5), (8, 5), (7, 5), (6, 5),
                  (5, 5), (5, 4), (5, 3), (6, 3), (7, 3), (7, 6), (7, 7), (7, 8), (7, 9), (8, 9), (9, 9), (9, 7), (10, 7)]:
            self.draw(self.wall, i[0], i[1])
            self.dic[(i[0], i[1])] = '墙'
        for i in self.ls:
            self.screen.blit(self.road, i)
            self.dic[(int((i[0]-375)/48), int((i[1]-25)/48))] = '路'
